function finished = stopStrategy( strategyType, generation, population )
    global maxGeneration tolOptimal prevBestFitness tolContent prevStdFitness tolStructure;
    
    
    switch strategyType 
        case 1 %MAX_GEN
            
            finished = generation < maxGeneration;
            
        case 2 %STRUCT
            
            %finished = true;
            %if mod(generation, 10) == 0
                actualMean = mean(population.fitness);
                stdFitness = std(population.fitness)/actualMean*100;
                finished = stdFitness > tolStructure;
            %    if abs(prevStdFitness - stdFitness) <= tolStructure
            %        finished = false;
            %    end
            %    prevStdFitness = stdFitness;
            %end
          
        case 3 %CONTENT
            
            finished = true;
            if mod(generation, 10) == 0
                maxCurrFitness = max(population.fitness);
                if abs(prevBestFitness - maxCurrFitness) <= tolContent
                    finished = false;
                end
                prevBestFitness = maxCurrFitness;
            end
            
        case 4 %OPTIMAL
            
            finished = max(population.fitness) < tolOptimal;
            
        otherwise 
            disp('error in stop strategy type');
    end
end

